/**
 * 轮播组件
 * @type {Request}
 */

Component({

  options: {
    addGlobalClass: true,
  },
  /**
   * 组件的属性列表
   */
  properties: {
    swiperList: Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    current: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    swiperchange(e) {
      this.setData({
        current:e.detail.current
      });
    },
    swipclick(e) {
      let that = this;
      let swip = that.data.swiperList[that.data.current];
      console.log(swip.transUrlType)
      if (swip.transUrlType === 1) {
        wx.navigateTo({
          url: '/pages/home/couponDetail/index?stockId=' + swip.transUrl
        });
      }else if (swip.transUrlType === 3) {
        wx.navigateToMiniProgram({
          appId: swip.transUrl,
          success(res) {
            console.log(res)
          },
          fail(res) {
            console.log(res)
          }
        })
      }else {
        wx.navigateTo({
          url: '/pages/home/merchant/webindex?transUrl=' + encodeURIComponent(swip.transUrl)
        })
      }
    },
  },

  lifetimes: {
    attached: function() {

    }
  },

})
